home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / bin / qt-language-selector < prev    next >
Text File  |  2008-10-27  |  2KB  |  71 lines

  1. #!/usr/bin/python
  2.  
  3. import sys
  4.  
  5. from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs, KCmdLineOptions
  6. from PyKDE4.kdeui import KApplication, KMessageBox
  7.  
  8. from PyKDE4.kdecore import *
  9. from PyKDE4.kdeui import *
  10.  
  11. from LanguageSelector.LanguageSelector import *
  12. from LanguageSelector.qt.QtLanguageSelector import QtLanguageSelector
  13. from gettext import gettext as i18n
  14.  
  15. def _(string):
  16.     return unicode(i18n(string), "utf-8")
  17.  
  18. if __name__ == "__main__":
  19.  
  20.     appName    = "language-selector"
  21.     catalog    = ""
  22.     programName = ki18n ("Language Selector")
  23.     version    = "0.3.4"
  24.     description    = ki18n ("Language Selector")
  25.     license    = KAboutData.License_GPL
  26.     copyright    = ki18n ("(c) 2008 Canonical Ltd")
  27.     text    = ki18n ("none")
  28.     homePage    = "https://launchpad.net/language-selector"
  29.     bugEmail    = ""
  30.     
  31.     aboutData    = KAboutData (appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail)
  32.     
  33.     aboutData.addAuthor(ki18n("Rob Bean"), ki18n("PyQt4 to PyKDE4 port"))
  34.  
  35.     options = KCmdLineOptions()
  36.     options.add("!mode ", ki18n("REQUIRED: install, uninstall or select must follow"),  "select")
  37.     options.add("+[install]", ki18n("install a language"))
  38.     options.add("+[uninstall]", ki18n("uninstall a language"))
  39.     options.add("+[select]", ki18n("select a language"))
  40.  
  41.     KCmdLineArgs.init (sys.argv, aboutData)
  42.     KCmdLineArgs.addCmdLineOptions(options)
  43.  
  44.     gettext.bindtextdomain("language-selector", "/usr/share/locale")
  45.     gettext.textdomain("language-selector")
  46.  
  47.     app = KApplication()
  48.     
  49.     args = KCmdLineArgs.parsedArgs()
  50.     
  51.     if args.isSet("mode"):
  52.         whattodo = args.getOption("mode")
  53.         if whattodo in ["install", "uninstall", "select"]:
  54.             pass
  55.         else:
  56.             print whattodo, "is not a valid argument"
  57.             args.usage()
  58.     else:
  59.         print "Please review the usage."
  60.         args.usage()
  61.         
  62.     if os.getuid() != 0:
  63.         KMessageBox.sorry(None, _("Please run this software with administrative rights."),  _("Not Root User"))
  64.         sys.exit(1)
  65.  
  66.     lc = QtLanguageSelector(app, "/usr/share/language-selector/", whattodo)
  67.     
  68.     lc.show()
  69.  
  70.     app.exec_()
  71.